#include <iostream>
#include <maythrow.impl.hpp>

#include "taihe/runtime.hpp"

namespace {
int32_t maythrow_impl(int32_t a) {
  if (a == 0) {
    taihe::set_error("some error happen");
    return -1;
  } else {
    int const tempnum = 10;
    return a + tempnum;
  }
}

maythrow::Data getDataMaythrow() {
  taihe::set_error("error in getDataMaythrow");
  return {
      taihe::string("C++ Object"),
      (float)1.0,
      {"data.obj", "file.txt"},
  };
}

void noReturnMaythrow() {
  taihe::set_error("error in noReturnMaythrow");
}

void noReturnBusinessError() {
  int errorcode = 5;
  taihe::set_business_error(errorcode, "error in noReturnBusinessError");
}
}  // namespace

// because these macros are auto-generate, lint will cause false positive.
// NOLINTBEGIN
TH_EXPORT_CPP_API_maythrow(maythrow_impl);
TH_EXPORT_CPP_API_getDataMaythrow(getDataMaythrow);
TH_EXPORT_CPP_API_noReturnMaythrow(noReturnMaythrow);
TH_EXPORT_CPP_API_noReturnBusinessError(noReturnBusinessError);
// NOLINTEND
